<template>
  <!-- <q-page style="background-color: #e5f1fd;" class="center">
    <q-spinner-hourglass color="primary" size="70px" :thickness="3" />
  </q-page> -->
  <q-page style="background-color: #e5f1fd;" class="column items-center">
    <img style="margin-top: 120px; width: 50px; height: 50px;" :src="getProdInfo.img || ''" alt="">
    <div style="margin-top: 10px; font-size: 16px; font-weight: 600;">{{ getProdInfo.name }}</div>
    <div style="margin-top: 30px; font-size: 14px; font-weight: 600;">您匹配的借贷产品</div>
    <div style="margin-top: 12px; font-size: 12px; color: #aaa;">正在为您跳转...</div>
  </q-page>

</template>

<script setup lang="ts">
import { computed, onMounted, onUnmounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
const route = useRoute();
const router = useRouter();
const url = route.query.url ? decodeURIComponent(route.query.url as string) : '';
const getProdInfo = computed(() => {
  return {
    img: sessionStorage.getItem("jumpProdImg"),
    name: sessionStorage.getItem("jumpProdName")
  } 
})
const open = () => {
  if (url && sessionStorage.getItem('openlink_tag')) {
    sessionStorage.removeItem('openlink_tag');
    location.replace(url);
  } else {
    const backPath = sessionStorage.getItem('openlink_back_path');
    router.push(backPath ?? '/waitPage');
  }
};

const visibilitychangeHandler = () => {
  if (!document.hidden) open()
}

document.addEventListener('visibilitychange', visibilitychangeHandler);
onUnmounted(() => {
  document.removeEventListener('visibilitychange', visibilitychangeHandler)
})
onMounted(() => {
  setTimeout(() => {
    open()
  }, 2000)
})
</script>

<style lang="scss" scoped></style>
